<?php

namespace Api\Controller;

use Think\Controller;

class EmptyController extends CommonController
{

    public function _initialize1()
    {
        $this->ajaxErrReturn('你访问的页面不存在-01');
    }

    public function _empty()
    {
        $this->ajaxErrReturn('你访问的页面不存在-02');
    }

    //自动搜索模块
    function autoSearch()
    {
        $tab_name = C('DB_PREFIX') . uncamelize(CONTROLLER_NAME);
        $sql = "SHOW TABLES LIKE '$tab_name'";
        $r = M()->query($sql);
        //dump(count($r));exit;
        if (count($r) == 0) {
            /*
            if(IS_AJAX || I('ajax')){
                $this->ajaxErrReturn('你访问的页面不存在');
            }else{
                $this->error('你访问的页面不存在');
            }
            */
            $this->ajaxErrReturn('你访问的页面不存在');
        }
        //判断模型是否存在
        $have_model = false;
        $model_name = CONTROLLER_NAME . 'Model.class.php';
        //当前模型位置
        $use_model_dir = APP_PATH . '\\' . MODULE_NAME . '\\Model\\' . $model_name;
        if (is_file($use_model_dir)) {
            $have_model = true;
        }
        //核心模型位置
        $com_model_dir = APP_PATH . 'Common\\Model\\' . $model_name;
        if (is_file($com_model_dir)) {
            $have_model = true;
        }
        if ($have_model) {
            $model = D(CONTROLLER_NAME);
            $wdata['status'] = 1; //默认字段,状态正常
            //$data = $model->getList($wdata);
        } else {
            $model = M(CONTROLLER_NAME);
            $wdata['status'] = 1; //默认字段,状态正常
            //$data = $model->getList($wdata);
        }
    }
}
